package com.sgb.kjwl.view.widget;

import android.content.Context;
import android.view.View;

import com.sgb.kjwl.R;
import com.swgk.core.dialog.PopViewHolder;
import com.swgk.core.favor.Default;

import java.util.List;

/**
 * @author by hq
 * 2021.03.15
 */
public class AddGoodsPopWindow extends BasePopWindow {

    protected OnClickCallBack onClickCallBack;

    public AddGoodsPopWindow(Context context) {
        super(context, DIR_DOWN_UP);
    }

    @Override
    protected int popLayout() {
        return R.layout.popwindow_add_goods;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        holder.getPop().findViewById(R.id.tv_copy).setOnClickListener(v -> {
            if (onClickCallBack != null) {
                onClickCallBack.copy();
            }
            dissMiss();
        });
        holder.getPop().findViewById(R.id.tv_add).setOnClickListener(v -> {
            if (onClickCallBack != null) {
                onClickCallBack.add();
            }
            dissMiss();
        });

        holder.getPop().findViewById(R.id.tv_cancel).setOnClickListener(v -> {
            if (onClickCallBack != null) {
                onClickCallBack.cancel();
            }
            dissMiss();
        });
    }

    @Override
    protected void setData(List data) {

    }

    @Override
    protected List getData() {
        return null;
    }

    public void setOnClickCallBack(OnClickCallBack onClickCallBack) {
        this.onClickCallBack = onClickCallBack;
    }

    public interface OnClickCallBack {
        /***
         * 复制当前商品
         */
        void copy();

        /***
         * 新增一条商品
         */
        void add();

        /***
         * 取消
         */
        void cancel();
    }

    @Override
    public void dismiss() {
        super.dismiss();
        clearAlpha();
    }
}
